package com.java.demo.model;

/**
 * 模版模式
 *
 * @auther zhangwj
 * @date 2020/12/11 下午2:54
 */
public class TemplatePattern {

    public static void main(String[] args) {
        Game game = new Cricket();
        game.play();
    }
}

abstract class Game {

    protected abstract void initialize();

    abstract void startGame();

    abstract void endGame();

    final void play() {
        initialize();
        startGame();
        endGame();
    }
}

class Cricket extends Game {

    @Override
    protected void initialize() {
        System.out.println("初始化游戏");
    }

    @Override
    void startGame() {
        System.out.println("开始玩游戏");
    }

    @Override
    void endGame() {
        System.out.println("结束游戏");
    }
}